
using System;
using System.Collections.Generic;
using UnityEngine;

namespace HareGame
{
    public partial class DataManager
    {
        [SerializeField]
        private List<MyIAPData> _IAPDatas = new List<MyIAPData>();

        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public MyIAPData GetMyIAPData(MyIAPID ID)
        {
            return GetData(ID.ToString(), _IAPDatas);
        }

        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public MyIAPData GetMyIAPData(string ID)
        {
            return GetData(ID, _IAPDatas);
        }

        public string GetID(string iAPID)
        {
            foreach (var v in _IAPDatas)
            {
                if (v.ProductID == iAPID.ToString())
                    return v.ID;
            }
            return null;
        }

        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns></returns>
        public List<MyIAPData> GetAllIAPData()
        {
            return _IAPDatas;
        }

        void InitMyIAPData()
        {
            _IAPDatas = GameEntry.Util.ReadJsonDataFromStreamAssets<MyIAPData>("MyIAP");
        }
    }
}
